﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace HigLabo.WindowsAzure.RestService.ServiceManagement
{
    public class ChangeDeploymentConfigurationBody
    {
        public String Configuration { get; private set; }
        public Boolean TreatWarningsAsError { get; private set; }
        public ChangeDeploymentConfigurationMode Mode { get; private set; }

        public ChangeDeploymentConfigurationBody
            (String configuration,
             Boolean treatWarningsAsError,
             ChangeDeploymentConfigurationMode mode)
        {            
            this.Configuration = configuration;
            this.TreatWarningsAsError = treatWarningsAsError;
            this.Mode = mode;
        }
        public String CreateText()
        {
            var ns = XNamespace.Get("http://schemas.microsoft.com/windowsazure");
            var doc = new XDocument();
            var root = new XElement(ns.GetName("ChangeConfiguration"));
            doc.Add(root);
            root.Add(new XElement(ns.GetName("Configuration"), Base64Converter.To(this.Configuration)));
            root.Add(new XElement(ns.GetName("TreatWarningsAsError"), this.TreatWarningsAsError ? "true" : "false"));
            root.Add(new XElement(ns.GetName("Mode"), this.Mode == ChangeDeploymentConfigurationMode.Auto ? "auto" : "manual"));
            return doc.ToString();
        }


    }
}
